import ZmUpload from '@/components/ZmUpload/components/main'
export const base = info => {
  const isTypeFour = info.form.product.type === '4'
  return [
    { name: '回款类型', label: 'returnedTypeName', valueClass: 'vm  ' },
    { name: '回款编号', label: 'returnedNo', valueClass: 'vm  ' },
    { name: '回款日期', label: 'returnedTime', valueClass: 'vm  ' },

    { name: '所属业务员', label: 'salesmanName', valueClass: 'vm  ' },
    { name: '所属部门', label: 'apartmentName', valueClass: 'vm  ' },
    {
      name: '关联客户',
      valueClass: 'vm  ',
      // label: 'customerName',
      render: (h, row, index) => {
        return [
          <el-button
            type="text"
            size="mini"
            class="pt10"
            onClick={() => {
              info.onExtendShow(info.form.customerId, 'customer')
            }}
          >
            {info.form.customerName}
          </el-button>
        ]
      }
    },

    { name: '销售单号', label: 'saleOrderNo', valueClass: 'vm  ' },
    {
      name: '关联销售名称',
      valueClass: 'vm  ',
      // label: 'customerName',
      render: (h, row, index) => {
        return [
          <el-button
            type="text"
            size="mini"
            class="pt10"
            onClick={() => {
              info.onExtendShow(info.form.saleId, 'sale')
            }}
          >
            {info.form.saleName}
          </el-button>
        ]
      }
    },
    {
      name: '回款单金额',
      // label: "yetReturnedMoney",
      valueClass: 'vm  ',
      render: (h, row, index) => {
        return <span class="vm  ">{info.form.initReturnedMoney}</span>
      }
    },
    {
      name: '红冲金额',
      // label: 'residue',
      valueClass: 'vm  ',
      render: (h, row, index) => {
        return <span class="vm  ">{info.form.balanceAmount}</span>
      }
    },
    // {
    //   name: info.form.returnedType === '1' ? '有效回款金额' : '红冲金额',
    //   label:
    //     info.form.returnedType === '1' ? 'validReturnedMoney' : 'balanceAmount',
    //   valueClass: 'vm  '
    // },
    {
      name: '有效回款金额',
      // label: 'residue',
      valueClass: 'vm  ',
      render: (h, row, index) => {
        return <span class="vm  ">{info.form.validReturnedMoney}</span>
      }
    },
    { name: '回款期数', label: 'returnedPeriodsName', valueClass: 'vm  ' },

    { name: '回款账期(天)', label: 'paymentsDays', valueClass: 'vm  ' },
    { name: '本次回款金额(元)', label: 'returnedMoney', valueClass: 'vm  ' },
    { name: '本次回款提成(元)', label: 'returnedPrice', valueClass: 'vm  ' },

    { name: '付款单位', label: 'payer', valueClass: 'vm  ' },
    { name: '交易方式', label: 'exchangeMeansName', valueClass: 'vm  ' },
    {
      name: '转账方式',
      label: 'transferTypeName',
      valueClass: 'vm  ',
      hide: info.form.exchangeMeans !== '2'
    },
    { name: '交易银行', label: 'dealBank', valueClass: 'vm  ' },
    { name: '收款单位', label: 'gatheringName', valueClass: 'vm  ' },
    { name: '交易流水号', label: 'transactionNo', valueClass: 'vm  ' },
    { name: '备注信息', label: 'remark', valueClass: 'vm  ' },
    { name: '回款操作人', label: 'operator', valueClass: 'vm  ' },
    {
      name: '回款凭证',
      valueClass: 'vm  ',
      render: (h, row, index) => {
        return (
          <div class="df">
            <zm-enclosure
              v-show={info.form.enclosureUrl}
              fileUrl={info.form.enclosureUrl}
            />
            <ZmUpload
              http-request={info.fileUpload}
              accept=".rar,.zip,.doc,.docx,.pdf,.png,.jpg,.pptx"
              limit={1}
              single-file-size={5}
            >
              <zm-button size="mini">
                {!info.form.enclosureUrl ? '上传' : '替换'}
              </zm-button>
            </ZmUpload>
          </div>
        )
      }
    },

    // 回款列表新增 业务场景详情、附件详情
    // {
    //   name: '业务场景',
    //   label: 'businessSceneName',
    //   valueClass: 'vm  '
    // },
    // {
    //   // hasIcon: true,
    //   // hide: isTypeThree,
    //   name: '相关附件',
    //   render: h => {
    //     // const saleTypeList = ['1', '2', '3', '4', '5']
    //     return [
    //       <div class="df-center">
    //         <span class="dib" v-show={!info.form.enclosureUrl}>
    //           无附件
    //         </span>
    //         <zm-enclosure
    //           v-show={info.form.enclosureUrl}
    //           fileUrl={info.form.enclosureUrl}
    //         />
    //         <ZmUpload
    //           // v-show={saleTypeList.includes(context.saleOrderType)}
    //           class="ml5"
    //           http-request={info.fileUpload}
    //           accept=".rar,.zip,.doc,.docx,.pdf,.png,.jpg,.pptx"
    //           limit={1}
    //           single-file-size={5}
    //         >
    //           <zm-button size="mini">
    //             {!info.form.enclosureUrl ? '上传' : '替换'}
    //           </zm-button>
    //         </ZmUpload>
    //       </div>
    //     ]
    //   }
    // },

    // 新增本期回款提成
    // { name: '本期回款提成', label: 'returnedPrice', valueClass: 'vm  ' },
    {
      hide: !isTypeFour,
      name: '销售单总价',
      label: 'saleTotalPrice'
    },
    {
      hide: !isTypeFour,
      name: '包场人数',
      label: 'number'
    },
    {
      hide: !isTypeFour,
      name: '销售单单价',
      label: 'salePrice'
    }
  ]
}

// 产品信息
export const product = info => {
  const _product = info.form.product
  return [
    { name: '产品编号', label: 'productCode', valueClass: 'vm  ' },
    {
      name: '产品名称',
      valueClass: 'vm  ',
      label: 'productName'
      /* render: (h, row, index) => {
        return [
          <el-button
            type="text"
            size="mini"
            class="pt10"
            onClick={() => {
              info.onExtendShow(_product.productId, 'product')
            }}
          >
            {_product.productName}
          </el-button>
        ]
      } */
    },
    { name: '产品类型', label: 'productTypeName', valueClass: 'vm  ' },
    {
      hide: _product.productType !== '3',
      name: '卡名称',
      label: 'cardName'
    },
    { name: '业务类型', label: 'businessTypeName', valueClass: 'vm  ' },

    {
      name: '次卡绑定产品',
      label: 'couponProductName',
      valueClass: 'vm  ',
      hide: _product.productType !== '4'
    },

    { name: '售货方式', label: 'saleTypeName', valueClass: 'vm  ' }, // 次卡产品信息
    {
      hide: _product.productType === '5',
      name: '产品面值',
      label: 'parValue',
      valueClass: 'vm  '
    },
    {
      hide: _product.productType !== '5',
      name: '优惠券面值',
      label: 'parValue',
      valueClass: 'vm  '
    },

    // {
    //   name: '理论成本',
    //   label: 'theoryCostPrice',
    //   valueClass: 'vm  ',
    //   hide: _product.productType !== '3'
    // },
    // {
    //   name: '实际成本',
    //   label: 'practiceCostPrice',
    //   valueClass: 'vm  ',
    //   hide: _product.productType !== '3'
    // },
    {
      name: '销售比例',
      valueClass: 'vm  ',
      hide: _product.productType !== '3',
      render: h => {
        return [
          <span>
            {_product.saleScalePrice +
              ':' +
              _product.saleScalePoint}
          </span>
        ]
      }
    },
    {
      name: '消费比例',
      valueClass: 'vm  ',
      hide: _product.productType !== '3',
      render: h => {
        return [
          <span>
            {_product.consumptionScalePrice +
              ':' +
              _product.consumptionScalePoint}
          </span>
        ]
      }
    },
    {
      hide: _product.productType !== '3',
      name: '销售类型',
      render: h => {
        return [
          <span>
            {_product.isCustomize === '1'
              ? '自定义金额'
              : '统一金额'}
          </span>
        ]
      }
    },
    {
      name: '销售单价(元)',
      label: 'salePrice',
      valueClass: 'vm  ',
      hide: _product.productType === '4'
    },
    {
      name: '销售单价(元)',
      valueClass: 'vm  ',
      hide: _product.productType !== '4',
      render: h => {
        return [<span>{_product.salePriceName}</span>]
      }
    },
    { name: '销售单总额(元)', label: 'saleTotalPrice', valueClass: 'vm  ' },
    { name: '数量(张)', label: 'number', valueClass: 'vm  ' },

    { name: '提成', label: 'proportion', valueClass: 'vm  ', unit: '%' },
    // {
    //   name: '实际提成(元)',
    //   label: 'actualProportionPrice',
    //   valueClass: 'vm  '
    // },
    // { name: '预估提成(元)', label: 'proportionPrice', valueClass: 'vm  ' },
    { name: '备注说明', label: 'remark', valueClass: 'vm  ' },
    {
      name: [1, 2, 5].includes(+_product.productType) ? '券号区间' : '卡号区间',
      label: [1, 2, 5].includes(+_product.productType) ? 'couponCodeDetail' : 'cardCodeDetail',
      valueClass: 'vm  ',
      hide: ([1, 2, 5].includes(+_product.productType) && !_product.couponCodeDetail) || ([3, 4].includes(+_product.productType) && !_product.cardCodeDetail)
    }
  ]
}

export const tabList = () => {
  return [
    {
      label: '基本信息',
      name: 'dataInfo'
    },
    {
      label: '审批记录',
      name: 'Record'
    },
    {
      label: '回款记录',
      name: 'RedDashedRecord'
    }
  ]
}

export const cinemaInfoList = [
  {
    name: '选择影院',
    type: 'cinemaType'
  },
  {
    name: '影院列表',
    type: 'url'
  },
  {
    name: '影片',
    type: 'filmName'
  },
  {
    hasIcon: true,
    name: '包场时间',
    type: 'date',
    start: 'startDate',
    end: 'endDate'
  },
  {
    hasIcon: true,
    name: '影厅备注',
    label: 'hallRemark'
  }
]

export const wenlvInfoList = [
  {
    name: '活动类型',
    label: 'typeName'
  },
  {
    name: '活动场地',
    label: 'address'
  },
  {
    name: '活动时间',
    type: 'date',
    start: 'startTime',
    end: 'endTime'
  },
  {
    name: '销售总额计算方式',
    label: 'calculationMethodName'
  },
  {
    name: '销售单价',
    label: 'unitPrice'
  },
  {
    name: '活动人数',
    label: 'joinCount'
  },
  {
    name: '销售总额',
    label: 'totalSalePrice'
  },
  {
    name: '活动备注',
    label: 'remark'
  }
]

export const cinemaColumns = ctx => {
  return [
    {
      prop: 'cinemaName',
      label: '影院名称'
    },
    {
      prop: 'cinemaCode',
      label: '影院编码'
    },
    {
      prop: 'interfaceName',
      label: '系统商'
    },
    {
      prop: 'cinemaLineName',
      label: '院线'
    },
    {
      label: '地区',
      render: (h, row) => {
        return [
          <span>
            {row.provinceName}-{row.cityName}-{row.countyName}
          </span>
        ]
      }
    }
  ]
}

export const redDashedRecordColumns = () => {
  return [
    {
      label: '回款编号',
      prop: 'returnedNo'
    },
    {
      label: '回款日期',
      prop: 'returnedTime'
    },
    {
      label: '回款类型',
      prop: 'returnedTypeName'
    },
    {
      label: '回款金额（元）',
      prop: 'returnedMoney'
    }
  ]
}

export const productListColumns = ctx => {
  return [
    {
      prop: 'name',
      label: '商品名称'
    },
    {
      prop: 'minSalePrice',
      label: '最低销售单价'
    },
    {
      prop: 'price',
      label: '销售单价'
    },
    {
      prop: 'number',
      label: '数量'
    },
    {
      prop: 'deliveryMoney',
      label: '运费'
    },
    {
      label: '商品总额',
      render: (h, row) => {
        return (
          <span>
            {(
              +row.price * +row.number +
              (+row.deliveryMoney || 0)
            ).toFixed(2)}
          </span>
        )
      }
    }
  ]
}
